/**
 * 
 */
package cn.edu.thsis.dao.impl;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

import cn.edu.thsis.pojo.mess;

public class BaseDao {

	public void close(Connection conn,PreparedStatement ps,ResultSet rs) {
		try {
			if(rs!=null) {
				rs.close();
			}
			if(ps!=null) {
				ps.close();
			}
			if(conn!=null) {
				conn.close();
			}
		} catch (SQLException e) {
			e.printStackTrace();
		}
	}
	
	//通用增删改
	public Integer executeCUD(String sql,Object[] obj) {
		Connection conn = null;
		PreparedStatement ps = null;
		Integer num = null;
		try {
			conn = jdbcUtils.getConnection();
			ps = conn.prepareStatement(sql);
			//参数值的数量等于sql语句的?
			for(int i=0;i<obj.length;i++) {
				ps.setObject(i+1,obj[i]);
			}
			num = ps.executeUpdate();
		} catch (Exception e) {
			e.printStackTrace();
		}finally {
			close(conn, ps, null);
		}
		return num;
	}

	/**
	 * @Title:messDao
	 * @Description:TODO
	 * @param:@param me
	 * @param:@return
	 * @return:boolean
	 * @throws
	 */
	public boolean messDao(mess me) {
		// TODO Auto-generated method stub
		return false;
	}
}
